﻿namespace StringsAndTextProcessing
{
    using System;
    using System.Collections.Generic;

    class ReversingWordsPlaces
    {
        // 1.2.13.13. Write a program that reverses the words in given sentence.
        // Example: "C# is not C++, not PHP and not Delphi!" -> "Delphi not and PHP, not C++ not is C#!".

        static void Main()
        {
            var text = "C# is not C++, not PHP and not Delphi!";

            var separators = new char[] { ' ', ',', '!', '?', '.' };
            var list = new List<string>(text.Split(separators, StringSplitOptions.RemoveEmptyEntries));

            for (var i = list.Count - 1; i >= 0; i--)
            {
                Console.Write(list[i] + " ");

                if (list[i] == "PHP")
                {
                    Console.Write(",");
                }
            }

            Console.Write("!");
        }
    }
}